package sales.managedbean;

import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import sales.entity.Product;
import sales.entity.SalesInquiry;
import sales.seesion.stateless.ProductManageSessionBean;

@ManagedBean
@ViewScoped
public class CreateProductManagedBean implements Serializable {

    @EJB
    ProductManageSessionBean productManageSessionBean;
    private Product product;
    private String productNameA,productNameB,productNameC,productNameD;
    private double promotionPriceA,promotionPriceB,promotionPriceC,promotionPriceD;
    private double basicPriceA,basicPriceB,basicPriceC,basicPriceD;
       
    public CreateProductManagedBean() {
        product = new Product();
    }

    public void saveNewProduct(ActionEvent event) throws IOException {
        
          List productNameList = new ArrayList<String>();
          List basicPriceList = new ArrayList<Double>();
          List promotionPriceList = new ArrayList<Double>();
         
         
         productNameList.add(getProductNameA());
         productNameList.add(getProductNameB());
         productNameList.add(getProductNameC());
         productNameList.add(getProductNameD());
         
         basicPriceList.add(getBasicPriceA());
         basicPriceList.add(getBasicPriceB());
         basicPriceList.add(getBasicPriceC());
         basicPriceList.add(getBasicPriceD());
         
         promotionPriceList.add(getPromotionPriceA());
         promotionPriceList.add(getPromotionPriceB());
         promotionPriceList.add(getPromotionPriceC());
         promotionPriceList.add(getPromotionPriceD());
         
    
        productManageSessionBean.saveNewProduct(productNameList,basicPriceList,promotionPriceList);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Product created.", ""));        
   }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getProductNameA() {
        return productNameA;
    }

    public void setProductNameA(String productNameA) {
        this.productNameA = productNameA;
    }

    public String getProductNameB() {
        return productNameB;
    }

    public void setProductNameB(String productNameB) {
        this.productNameB = productNameB;
    }

    public String getProductNameC() {
        return productNameC;
    }

    public void setProductNameC(String productNameC) {
        this.productNameC = productNameC;
    }

    public String getProductNameD() {
        return productNameD;
    }

    public void setProductNameD(String productNameD) {
        this.productNameD = productNameD;
    }

    public double getPromotionPriceA() {
        return promotionPriceA;
    }

    public void setPromotionPriceA(double promotionPriceA) {
        this.promotionPriceA = promotionPriceA;
    }

    public double getPromotionPriceB() {
        return promotionPriceB;
    }

    public void setPromotionPriceB(double promotionPriceB) {
        this.promotionPriceB = promotionPriceB;
    }

    public double getPromotionPriceC() {
        return promotionPriceC;
    }

    public void setPromotionPriceC(double promotionPriceC) {
        this.promotionPriceC = promotionPriceC;
    }

    public double getPromotionPriceD() {
        return promotionPriceD;
    }

    public void setPromotionPriceD(double promotionPriceD) {
        this.promotionPriceD = promotionPriceD;
    }

    public double getBasicPriceA() {
        return basicPriceA;
    }

    public void setBasicPriceA(double basicPriceA) {
        this.basicPriceA = basicPriceA;
    }

    public double getBasicPriceB() {
        return basicPriceB;
    }

    public void setBasicPriceB(double basicPriceB) {
        this.basicPriceB = basicPriceB;
    }

    public double getBasicPriceC() {
        return basicPriceC;
    }

    public void setBasicPriceC(double basicPriceC) {
        this.basicPriceC = basicPriceC;
    }

    public double getBasicPriceD() {
        return basicPriceD;
    }

    public void setBasicPriceD(double basicPriceD) {
        this.basicPriceD = basicPriceD;
    }


}
